Cross-tab reports

This kind of report has table structure, which means that it consists of lines and columns. At the same time, it is not known beforehand, how many lines and columns a table would possess. That is why a report grows not only downwards (as the report types examined above) but sideways as well. A typical example of a report of such type is shown below.

Let us examine the elements of the table:

In the picture, we see a table with two lines and four columns, where "a" and "b" are line titles, "1," "2," "3," and "4" are column titles, and "a1".."a4," "b1".."b4" are cells. To construct a report like this, we need just one set of data (a query or a table), which has three fields and contains the following data:

a 1 a1
a 2 a2
a 3 a3
a 4 a4
b 1 b1
b 2 b2
b 3 b3
b 4 b4

As you can see, the first field contains a line number, the second one have a column number, and the third one contains the cell contents at intersection of the table with the selected number. When constructing a report, FastReport creates a table in memory and fills it with data. Thus, the table expands dynamically, if a line or a column with a specified number does not exist.

Titles can consist of more than one level. Let us examine the following example:

In this example, the number, or index of the column is composite, i.e. it consists of two values. This report requires the following data:

a 10 1 a10.1
a 10 2 a10.2
a 20 1 a20.1
a 20 2 a20.2
b 10 1 b10.1
b 10 2 b10.2
b 20 1 b20.1
b 20 2 b20.2

In this example, the first field contains the line index, as it was before; the second and the third fields contain column indexes. The last field contains the cell value. Let us examine the following picture in order to make it clear, how FastReport constructs a tables with complex titles:

Before handling is accomplished, our table would look like the table shown in the picture. During handling, FastReport unites the title cells with equal values, which are allocated on one level.

The next table element, which is shown in the following picture, displays intermediate totals and totals:

This report is constructed using the same data, as were used in the previous one. The columns, highlighted with gray in the picture, are calculated automatically and are not included into the initial data set.